
import { asyncComponent } from 'react-async-component';
import {Spin} from 'antd'
const asyncComp = (Resolve,loading=false,ErrorComponent = null) => {
    const data = {};
    data.resolve = Resolve;
    if (loading) {
        data.LoadingComponent = ({ id }) => (
            <Spin
                tip="模块加载中..."
                spinning />
        )
    }

    if (ErrorComponent) {
        data.ErrorComponent = () => ErrorComponent;
    } else {
        data.ErrorComponent = ({ error }) => <div>页面丢失了,{error.message}</div>
    }
    return (
        asyncComponent({ ...data })
    )
}

export { asyncComp } 